<template>
  <cloudPage :isLoading="info == null">
    <cloudHeader slot="gHeader">
      <view class="grace-header-body">
        <!-- 返回按钮 -->
        <view
          class="grace-header-icons grace-icons icon-arrow-left"
          @tap.stop="handleNavBack"
          style="color: #000;"
        ></view>
        <!-- 中间内容 -->
        <view class="grace-header-content-noflex grace-text-center font-32" style="color: #000;font-weight: 600;">
          {{ $t("common.title.detailed") }}
        </view>
        <!-- 右侧按钮 -->
        <view class="icons grace-icons" style="font-size: 38rpx"></view>
      </view>
    </cloudHeader>
    <view class="gbody main" v-if="info != null">
      <view class="detailed">
        <view class="header">
          <view class="title">{{ info.value.title }}</view>
          <view class="footer">
            <view class="label">{{ $t("common.title.announcement") }}</view>
            <view class="time">
              {{ info.updated_at | moment("YYYY-MM-DD HH:mm:ss") }}
            </view>
          </view>
        </view>
        <view class="body">
          <cloudHtml :html="info.value.content"></cloudHtml>
        </view>
      </view>
    </view>
  </cloudPage>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
export default {
  data() {
    return {
      id: null,
      info: null,
    };
  },
  async onLoad({ id }) {
    if (!id) {
      this.handleNavTo({ url: "/pages/announcement/index" });
      return;
    }
    this.id = id;
    let info = await this.getAnnouncementById(id);
    this.info = info;
  },
  methods: {
    ...mapActions("announcement", ["getAnnouncementById"]),
  },
};
</script>

<style scoped>
.main {
  height: 100vh;
  background-color: #fff;
}
.detailed {
  padding: 0rpx 20rpx;
}
.header {
    padding: 20px 0px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
.header .title {
  height: 48rpx;
  font-size: 34rpx;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #ffffff;
  line-height: 48rpx;
  margin-bottom: 24rpx;
}
.header .footer {
  display: flex;
  align-items: center;
}
.header .footer .label {
      background-size: 100% 100%;
      background-repeat: no-repeat;
      text-align: center;
      color: #000;
      font-size: 14px;
      padding: 0 5px;
      box-sizing: border-box;
}
.header .footer .time {
    font-size: 12px;
    font-weight: 400;
    color: #989898;
    margin-left: auto;
}
.body {
    padding-top: 15px;
    /*text-indent: 1rem;*/
    color: #6d6d6d;
}
</style>
